<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'timeZone'=>'Asia/Chongqing',
    'components' => [

//        'redis' => [
//            'class' => 'yii\redis\Connection',
//            'hostname' => '192.168.126.128',
//            'port' => 6379,
//            'database' => 0,
//            'password'=>123
//        ],
        'cache'=> [
            'class' => 'yii\caching\FileCache',
        ],
//        'cache' => [
//            'class' => 'yii\redis\Cache',
//        ],
//        'session'=>[
//            'class'=>'yii\redis\Session',
//        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'VM04qJRgdelX6LKsrNTESelAsknWS7C1',
        ],


        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            //'viewPath' => '@common/mail',
            'useFileTransport' => false,    //这里一定要改成false，不然邮件不会发送
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.163.com',
                'username' => 'weisendo@163.com',
                'password' => 'liwei13569980170',        //如果是163邮箱，此处要填授权码
                'port' => '25',
                'encryption' => 'tls',
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],

        //国际化
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/messages',
                    'sourceLanguage' => 'en',       //源语言使用en, 方便使用en-US为目标语言
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
            ],
        ],
        //数据1
        'db' => require(__DIR__ . '/db.php'),
        //数据2
       // 'dbq' =>require(__DIR__.'/db2.php'),
        //数据3
        'urlManager' => [
//            'caseSensitive' => true,//路由是否区分大小写
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                    [
                        'class' => 'yii\rest\UrlRule',
                        'controller' => ['book','bookarticle','test','images'],
                        'pluralize' => false,
                    ],
           ],
        ],
    ],

//    'user' => [
//        'identityClass' => 'models\User',
//        #   'enableAutoLogin' => true,
//    ],
    'language' => 'zh-CN',

    'params' => $params,
    'modules' => [
	    'portal' => [
		    'class' => 'app\modules\portal\portal',
	    ],
	    'manage' => [
		    'class' => 'app\modules\manage\manage',
	    ],
        'test' => [
            'class' => 'app\modules\test\Module',
        ],
    ],
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
